<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>复制一个cURL句柄和它的所有选项</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.curl-copy-handle" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">curl_copy_handle</h1>
  <p class="verinfo">(PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">curl_copy_handle</span> &mdash; <span class="dc-title">复制一个cURL句柄和它的所有选项</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.curl-copy-handle-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>curl_copy_handle</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$ch</code></span>
   ) : <span class="type">resource</span></div>

  <p class="para rdfs-comment">
   复制一个cURL句柄并保持相同的选项。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.curl-copy-handle-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    <dt>
<code class="parameter">ch</code>
</dt>
<dd>
<p class="para">由 <span class="function"><a href="curl_init.html" class="function">curl_init()</a></span> 返回的 cURL 句柄。</p></dd>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.curl-copy-handle-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回一个新的cURL句柄。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.curl-copy-handle-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5236">
    <p><strong>Example #1 复制一个cURL句柄</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;创建一个新的cURL资源<br /></span><span style="color: #0000BB">$ch&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">curl_init</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">//&nbsp;设置URL和相应的选项<br /></span><span style="color: #0000BB">curl_setopt</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">CURLOPT_URL</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'http://www.example.com/'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">curl_setopt</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">CURLOPT_HEADER</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;复制句柄<br /></span><span style="color: #0000BB">$ch2&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">curl_copy_handle</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;抓取URL&nbsp;(http://www.example.com/)&nbsp;并把它传递给浏览器<br /></span><span style="color: #0000BB">curl_exec</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch2</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;关闭cURL资源，并且释放系统资源<br /></span><span style="color: #0000BB">curl_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">curl_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>

</div></div></div></body></html>